﻿/**	thread.h
 *	----	Create Time Stamp	--2005-11-13 00:08:13--
 *-----------------------------------------------------------------------------
 *	Mean	:线程对象
 *	Author	:Nick Shallery	(nicknide@gmail.com)
 *	Version	:1.1.24.26	(2008-10-17 00:34:06)
 *-----------------------------------------------------------------------------
**/	/*YOU HAVE ALL LEFT WITH THIS CODE WHILE YOU KEEP COMMENT IN EVERY COPY.*/


#if			!defined(__LOLIX__LOLI__THREAD__NICK__K_IN_G__)
#define		__LOLIX__LOLI__THREAD__NICK__K_IN_G__


#if			!defined(__LOLIX__LOLI_X_CFG__K_IN_G__)
	#include	"../lolix_cfg.h"
#endif	//	!defined(__LOLIX__LOLI_X_CFG__K_IN_G__)

#if			!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
	#include	"../lolix_type.h"
#endif	//	!defined(__LOLIX__LOLIX_TYPE__K_IN_G__)
#if			!defined(__LOLIX__TOY__TIME_TYPES__K_IN_G__)
	#include	"../toy/time_types.h"
#endif	//	!defined(__LOLIX__TOY__TIME_TYPES__K_IN_G__)
#if			!defined(__LOLIX__TOY__REBIND_TYPE__K_IN_G__)
	#include	"../toy/rebind_type.hpp"
#endif	//	!defined(__LOLIX__TOY__REBIND_TYPE__K_IN_G__)


namespace lolix{namespace loli{
	class	thread;
}}

namespace lolix{namespace toy{
	class time_span;
}}


class	LOLIX_NO_VTABLE	lolix::loli::thread
	: public itf
{
public:
	LOLIX_DECLARE_ITF(lolix::loli::thread, lolix::itf, (0x93623933, 0x238f4321, 0x8503338c, 0xbb9e26e7));
	LOLIX_DEFINE_FACTORY((0xb9319a7d, 0x26a94b95, 0x94b768c1, 0xd3bfbb8b), (thread** out_ptr));

	class query;
	enum ENUM_THREAD_START;
	enum ENUM_THREAD_STATE;

	LOLIX_INTERFACE(start	, LOLIX_RETNV, (size_type start_param, query*));
	LOLIX_INTERFACE(suspend	, LOLIX_RETNV, (size_type* out_stimes));
	LOLIX_INTERFACE(resume	, LOLIX_RETNV, (size_type* out_stimes));
	LOLIX_INTERFACE(kill	, LOLIX_RETNV, (size_type exit_code));
	LOLIX_INTERFACE(wait	, LOLIX_RETNV, (LOLIX_RETNV* exit_id, const toy::time_span*)const);
	LOLIX_INTERFACE(sleep	, LOLIX_RETNV, (toy::time_span*));
	LOLIX_INTERFACE(state	, LOLIX_RETNV, (ENUM_THREAD_STATE*)const);
};


class	LOLIX_NO_VTABLE	lolix::loli::thread::query
	: public itf
{
public:
	typedef	LOLIX_RETNV	value_type;
	LOLIX_DECLARE_ITF(lolix::loli::thread::query, lolix::itf, (0xf124c5e5, 0x28a04730, 0x9380e95e, 0xb3a843d4));
	//	工作函数
	LOLIX_INTERFACE(invoke, LOLIX_RETNV, (void));
};


enum lolix::loli::thread::ENUM_THREAD_START
{
	THREAD_START_NORMAL		= 0,	//	start normal
	THREAD_START_TRAP		= 1,	//	trap model
	THREAD_START_SUSPEND	= 2,	//	start at SUSPEND

	THREAD_START_VER		= 1,
};


enum lolix::loli::thread::ENUM_THREAD_STATE
{
	THREAD_STATE_IDLE		,	//	空闲, 工作完毕后的状态
	THREAD_STATE_WORK		,	//	工作
	//	-----------------------------------
	THREAD_STATE_NUM		,
	THREAD_STATE_VER = 2
};


SYS_REGIST_TYPE(lolix::loli::thread);
SYS_REGIST_TYPE(lolix::loli::thread::ENUM_THREAD_START);
SYS_REGIST_TYPE(lolix::loli::thread::ENUM_THREAD_STATE);
SYS_REGIST_TYPE(lolix::loli::thread::factory_type);
SYS_REGIST_TYPE(lolix::loli::thread::query);

#endif	//	!defined(__LOLIX__LOLI__THREAD__NICK__K_IN_G__)



